<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    {include file='public/_meta' /}
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" name="submitform" id="submitform" method="post">
            <div class="layui-form-item">
                <label for="title" class="layui-form-label">
                    <span class="x-red">*</span>分类标题
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="title" name="title" value="{$info.title}" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="icon_code" class="layui-form-label">
                    <span class="x-red">*</span>图标码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="icon_code" name="icon_code" value="{$info.icon_code}" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="is_show1" class="layui-form-label">
                    <span class="x-red">*</span>是否显示
                </label>
                <div class="layui-input-inline">
                    <input type="radio" name="is_show" id="is_show1" value="1" title="是" {if $info.is_show=='1'}checked="true"{/if} >
                    <input type="radio" name="is_show" id="is_show2" value="0" title="否" {if $info.is_show=='0'}checked="true"{/if} >
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="add">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        //监听提交
        form.on('submit(add)',
            function(data) {
                //发异步，把数据提交给php
                var formdata = {
                    'title': data.field.title,
                    'is_show' : data.field.is_show,
                    'icon_code' : data.field.icon_code,
                    'id' : "{$info.id}"
                };

                //console.log(formdata);
                $.getJSON("{:url('admin/atype/editdo')}",formdata,function(res){

                    if(parseInt(res.statusCode)==200){
                        layer.msg(res.message, {
                                icon: 6
                            },
                            function() {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            }
                        );
                    }else{
                        layer.message(res.message);
                    }
                });
                return false;
            });

    });
</script>

</body>

</html>
